<?php

namespace App\Http\Controllers\View;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Services\UserService;
use App\Facades\Utils\ValidateParameter;

class UserController extends Controller
{
    public function index(Request $request){
        // dd(UserService::getUsers()->toArray());

        return view('pages.user.list',[
        	'users' => UserService::getUsers()
        ]);
    }

    public function info(Request $request){

    	$rules = [
    		'id' => 'required|exists:wechat_users,id'
    	];

    	ValidateParameter::validate($request,$rules);

    	$data=$request->all();

    	return view('pages.user.info',[
    		'user' => UserService::getUser($data)
    	]);
    }

    public function giRecord(Request $request){

    	$rules = [
    		'id' => 'required|exists:wechat_users,id'
    	];

    	ValidateParameter::validate($request,$rules);

    	$data=$request->all();

    	UserService::getUserByGiRecord($data);

    	return view('pages.user.girecord',[
    		'giRecords' => UserService::getUserByGiRecord($data)
    	]);
    }

    public function weight(Request $request){

    	$rules = [
    		'id' => 'required|exists:wechat_users,id'
    	];

    	ValidateParameter::validate($request,$rules);

    	$data=$request->all();
        // dd(UserService::getUserByWeight($data)->toArray());
    	return view('pages.user.weight',[
    		'weights' => UserService::getUserByWeight($data)
    	]);
    }
}
